cc.Class({
    extends: require('wy-Component'),

    properties: {
        bg: cc.Node,
        bgBorder: cc.Node,
        text: cc.Label,
        _options: {
            default: {}
        }
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad: function () {
        this._options = {
            width: 450,
        }
        this.setPercent(0)
    },
    setOptions: function (options) {
        Object.assign(this._options, options);
        this.bg.width = this._options.width;
        this.bgBorder.width = this._options.width;
    },
    //设置显示百分比
    setPercent: function (percent) {
        this.bg.width = (this._options.width - 60) * percent + 60;
        this.text.string = `${percent * 100}%`;
    },
    start() {
        //setTimeout(() => {
        //    this.setPercent(10);
        //}, 1000);
        //setTimeout(() => {
        //    this.setPercent(20);
        //}, 2000);
        //setTimeout(() => {
        //    this.setPercent(30);
        //}, 3000);
        //setTimeout(() => {
        //    this.setPercent(40);
        //}, 4000);
        //setTimeout(() => {
        //    this.setPercent(50);
        //}, 5000);
        //setTimeout(() => {
        //    this.setPercent(60);
        //}, 6000);
        //setTimeout(() => {
        //    this.setPercent(70);
        //}, 7000);
        //setTimeout(() => {
        //    this.setPercent(80);
        //}, 8000);
        //setTimeout(() => {
        //    this.setPercent(90);
        //}, 9000);
        //setTimeout(() => {
        //    this.setPercent(100);
        //}, 10000);
    },
});
